package com.demo.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * GatewayConfigtion
 *
 * @author liujin
 * @date 2020/12/3 18:06
 */
@Configuration
public class GatewayConfigtion {

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        RouteLocatorBuilder.Builder routes = builder.routes();
        routes.route(predicateSpec -> predicateSpec.path("/manger/**").uri("lb://manger").id("mangerService"))
                .route(predicateSpec -> predicateSpec.path("/customer/**").uri("lb://customer").id("customerService"))
                .route(predicateSpec -> predicateSpec.path("/oauth/**").uri("lb://authorizationserver").id("AuthorizationServer"));
        return routes.build();
    }
}
